package com.huo.designmode.simpleFactory;

public class MainClass {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {

        //测试1 使用的多态
        Fruit apple = new Apple();
        Fruit banana = new Banana();
        apple.get();
        banana.get();

        //测试2
        Fruit apple2 = FactoryFruit.getApple();//工厂类可以被外部直接调用，创建所需要的产品对象。
        Fruit banana2 = FactoryFruit.getBanana();
        apple2.get();
        banana2.get();

        //方法3 使用简化后的代码调用
        Fruit apple3 = FactoryFruit.getFruit( "Apple" );//注意是Apple
        apple3.get();


    }

}
